﻿@using Entity.ProjectEnt
@using ZFine.Application.Project
@using ZFine.Code
@{
    ViewBag.Title = "Details";
    Layout = "~/Views/Shared/_Index.cshtml";
    List<ClientPlay> jihualist = ViewData["jihualist"] as List<ClientPlay>;
    OperationGudaoCarEntity operation = ViewData["operationent"] as OperationGudaoCarEntity;
    if (operation == null)
    {
        operation = new OperationGudaoCarEntity();
    }

}
<link href="~/Content/js/dialog/dialog.css" rel="stylesheet" />
<script src="~/Content/js/dayin/jquery.jqprint-0.3.js"></script>
<script>
    var keyid = '@operation.F_Id';
    function CancelFangXing(fid) {
        $.modalConfirm("注：您确定要放行吗？",
            function (r) {
                if (r) {
                    $.submitForm({
                        url: "/Project/GudaoCar/CancelPass",
                        param: { keyValue: fid },
                        close: false,
                        success: function () {
                            $.reload();
                        }
                    });
                }
            });
    }

    function ModifyInfo(fid) {
        $.modalOpen({
            id: "Form",
            title: "修改车辆信息",
            url: "/Project/Pathway/Edit?keyValue=" + fid,
            width: "520px",
            height: "630px",
            callBack: function (iframeId) {
                top.frames[iframeId].submitForm();
                setTimeout(function () {
                    //$("#loadingPage").css("display", "none");
                    //$("#gridList").children().empty();
                    $.reload();
                    //gridList();
                },
                    1000);
            }
        });
    }
    function saveIntoDrafts() {
        $.modalConfirm("注：您确定要执行计划操作吗？",
            function (r) {
                if (r) {
                    $("#btn_next").attr({ "disabled": "disabled" });
                    //$.submitForm({
                    //    url: "/Project/ExecuteWorkPlan/ExecutePlan",
                    //    param: { keyValue: keyid },
                    //    close: true,
                    //    success: function (data) {
                    //        if (data.code > 0) {//成功
                    //            alert(data.msg);
                    //        } else {//失败
                    //            alert(data.msg);
                    //        }
                    //        $.modalClose();
                    //    }
                    //});
                    $.ajax({
                        url: "/Project/ExecuteWorkPlan/ExecutePlan",
                        data: { keyValue: keyid },
                        type: "post",
                        dataType: "json",
                        success: function (data) {
                            if (data.code > 0) {//成功
                                $.modalMsg(data.msg, "success");
                            } else {//失败

                                $.modalMsg(data.msg, "error");
                            }
                            debugger;
                            //var sss = $(this);
                            //$(this).find(".toolbar").children().children().first().click();
                            //$(".vZFine_ifram").each(function () {
                            //    debugger;
                            //    if ($(this).css("display") != "none") {
                            //        alert("222");
                            //        $(this).find(".toolbar").children().children().first().click();
                            //    }
                            //});
                            $.currentWindow().$("#gridList").trigger("reloadGrid");
                            $("#btn_next").removeAttr("disabled");
                            $.modalClose();

                        }
                    });
                }

            });
    }
    function saveReturnPlay() {
        $.modalConfirm("注：您确定要回退计划操作吗？",
            function (r) {
                if (r) {
                    $("#btn_last").attr({ "disabled": "disabled" });
                    //$.submitForm({
                    //    url: "/Project/ExecuteWorkPlan/ExecuteReturnPlan",
                    //    param: { keyValue: keyid },
                    //    close: false,
                    //    success: function (data) {
                    //        if (data.code > 0) {//成功
                    //            alert(data.msg);
                    //        } else {//失败
                    //            alert(data.msg);
                    //        }
                    //        $.modalClose();
                    //    }
                    //});
                    $.ajax({
                        url: "/Project/ExecuteWorkPlan/ExecuteReturnPlan",
                        data: { keyValue: keyid },
                        type: "post",
                        dataType: "json",
                        success: function (data) {
                            if (data.code > 0) {//成功
                                $.modalMsg(data.msg, "success");
                            } else {//失败

                                $.modalMsg(data.msg, "error");
                            }
                            $.currentWindow().$("#gridList").trigger("reloadGrid");
                            $("#btn_last").removeAttr("disabled");
                            $.modalClose();

                        }
                    });
                }
            });
    }

    function preview() {
        $("#divDaYin").jqprint({
            debug: false,
            importCSS: true,
            printContainer: true,
            operaSupport: true
        });
    }
</script>
<style>
    table tbody tr td {
        text-align: center;
    }
</style>
<form id="form1">
    <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;padding-bottom: 70px;">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#">操作信息信息</a></li>
        </ul>
        <div style="padding-top: 20px; margin-right: 30px;" id="divDaYin">
            <div style="width: 100%; text-align: center; font-size: 24px;margin-bottom: 10px">
                新畅铁路调车作业单
            </div>

            @{
                if (string.IsNullOrEmpty(operation.WorkPlan.PlayNum))
                {
                    <div style="width: 100%; text-align: center; font-size: 18px; margin-bottom: 10px" >
                        <span>第1批计划</span>
                    </div>
                }
                else
                {
                    <div style="width: 100%; text-align: center; font-size: 18px; margin-bottom: 10px">
                        <span>第</span>
                        <span> @operation.WorkPlan.PlayNum</span>
                        <span>批计划</span>
                       
                    </div>
                }
            }

            <div style="width: 100%; text-align: center; font-size: 16px; margin-bottom: 10px">
                <span id="">@operation.WorkPlan.BeginDateTime.ToDateTimeString()</span>
                <span>&nbsp;&nbsp;至&nbsp;&nbsp;</span>
                <span id="">@operation.WorkPlan.EndDateTime.ToDateTimeString()</span>
            </div>
            <table class="form table-bordered" style="margin-bottom: 20px;">
                @*<tr>
                        <th class="formTitle" valign="top" style="padding-top: 5px;">计划创建时间：</th>
                        <td class="formValue">
                            @(operation == null ? "" : operation.F_CreatorTime.Value.ToString("YYYY-MM-dd hh:mm:ss"))
                        </td>
                    </tr>*@
                @*<tr>
                        <th class="formTitle" valign="top" style="padding-top: 5px;">是否执行：</th>
                        <td class="formValue">
                            @if (operation.IsExecute == true)
                            {
                                @:  <span style="color:forestgreen">已执行</span>
                            }
                            else
                            {
                                @:  <span style="color:red">未执行</span>
                            }

                        </td>
                        <th class="formTitle" valign="top" style="padding-top: 5px;">执行时间：</th>
                        <td class="formValue">

                            @if (operation.ExecuteDateTime == null)
                            {
                                @:  <div style="color:red">无</div>
                            }
                            else
                            {
                                @:  <span style="color:forestgreen">@operation.ExecuteDateTime.Value.ToString("yyyy-MM-dd HH:mm:ss")</span>
                            }
                        </td>
                    </tr>*@

                <tr>
                    <th class="formTitle" valign="top" style="padding-top: 5px;width: 12%">调车长:</th>
                    <td class="formValue">
                        @*<span style="color:forestgreen">已执行</span>*@
                        @if (operation.WorkPlan != null && operation.WorkPlan.DiaoChePersion != null)
                        {
                            @: <div style="color: forestgreen; text-align: center;margin-left: 5px">@operation.WorkPlan.DiaoChePersion.F_RealName</div>
                        }
                        else
                        {
                            @: <span style="color: red">无</span>
                        }
                        @*@(operation.IsExecute == true ? "" : "")*@
                    </td>
                    <th class="formTitle" valign="top" style="padding-top: 5px;width: 12%">调度员:</th>
                    <td class="formValue">

                        @if (operation.WorkPlan != null && operation.WorkPlan.DiaoDuPerson != null)
                        {
                            @:<div style="color: forestgreen; text-align: center;margin-left: 5px">@operation.WorkPlan.DiaoDuPerson.F_RealName</div>
                        }
                        else
                        {
                            @: <span style="color: red">无</span>
                        }
                        @*@(operation.ExecuteDateTime == null ? "<div style=\"color:red\">无</div>" : operation.ExecuteDateTime.Value.ToString("YYYY-MM-dd hh:mm:ss"))*@
                    </td>
                </tr>

                @*<tr>
                        <th class="formTitle" valign="top" style="padding-top: 5px;">是否回退：</th>
                        <td class="formValue">
                            @if (operation.IsRollBack == true)
                            {
                                @: <div style="color:red">已回退</div>
                            }
                            else
                            {
                                @:  <div style="color:forestgreen">未回退</div>
                            }

                        </td>
                        <th class="formTitle" valign="top" style="padding-top: 5px;">回退时间：</th>
                        <td class="formValue">
                            @if (operation.RollbackTime == null)
                            {
                                @: <div style="color:red">无</div>
                            }
                            else
                            {
                                @:  <span style="color:forestgreen">@operation.RollbackTime.Value.ToString("yyyy-MM-dd HH:mm:ss")</span>
                            }

                        </td>
                    </tr>*@
            </table>
            <table class="form table  table-bordered table-hover" style="padding-bottom: 15px;">
                <thead>
                    <tr>
                        <th style="text-align: center">方向</th>
                        <th style="text-align: center">股道</th>
                        <th style="text-align: center">方法</th>
                        <th style="text-align: center">车数</th>
                        <th style="text-align: center">记事</th>
                    </tr>
                </thead>
                <tbody>
                    @{
                        foreach (var item in jihualist)
                        {
                            <tr>
                                <td style="text-align: center">
                                    @item.fangxiang
                                </td>
                                <td style="text-align: center">
                                    @item.gudao
                                </td>
                                <td style="text-align: center">
                                    @item.fangfa
                                </td>
                                <td style="text-align: center">
                                    @item.cheshu
                                </td>
                                <td style="text-align: center">
                                    @item.jishi
                                </td>
                            </tr>
                        }
                    }

                </tbody>
            </table>
        </div>
        <div class="form-button" id="wizard-actions" style="text-align: center; position:fixed">
            <a id="btn_last" class="btn btn-default notexecute" onclick="saveReturnPlay()">回退</a>
            <a id="btn_next" class="btn btn-default execute" onclick="saveIntoDrafts()">执行</a>
            <a id="btn_dayin" class="btn btn-default prin" onclick="preview()">打印</a>
        </div>
    </div>
</form>
